package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/circle-and-rectangle-overlapping/
 * @create 2025/11/15 10:35
 * @since JDK17
 */

class Solution58 {
    int f(int x, int y, int k) {
        if (x <= k && k <= y) {
            return 0;
        }
        return k < x ? x - k : k - y;
    }
    public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
        int a = f(x1, x2, xCenter), b = f(y1, y2, yCenter);
        return a * a + b * b <= radius * radius;
    }
}